<?php
/**
* @version $Id: profilebox.php 2059 2010-03-14 03:42:18Z mahagr $
* Kunena Component
* @package Kunena
*
* @Copyright (C) 2008 - 2009 Kunena Team All rights reserved
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link http://www.kunena.com
*
* Based on FireBoard Component
* @Copyright (C) 2006 - 2007 Best Of Joomla All rights reserved
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @link http://www.bestofjoomla.com
*
* Based on Joomlaboard Component
* @copyright (C) 2000 - 2004 TSMF / Jan de Graaff / All Rights Reserved
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @author TSMF & Jan de Graaff
**/

// Dont allow direct linking
defined( '_JEXEC' ) or die('Restricted access');

require_once (KUNENA_PATH_LIB.DS . 'kunena.login.php');

if ($type == 'logout')
{
?>
    <table width = "100%" border = "0" cellspacing = "0" cellpadding = "0" class = "fb_profilebox" >
        <tbody id = "topprofilebox_tbody">
            <tr class = "<?php echo $boardclass ;?>sectiontableentry1">
                <form action="index.php" method="post" name="login">
                                <td  class = "td-1  fbs" align="center" width="1%" style="border:1px solid #cccccc; padding:5px; width:50px; height:50px;">
<?php echo CKunenaLink::GetProfileLink($fbConfig, $kunena_my->id, $jr_avatar);?>
                                </td>
                                <td valign = "top" class = "td-2  fbm fb_profileboxcnt" align="left">
        <div style="float:left; padding-right:10px; padding-left:5px; font-size: small;">
                <div>
               <?php echo _PROFILEBOX_WELCOME; ?>,
                <b><?php echo $jr_username; ?></b>
                </div>
                <div>
                        <div style="padding-top:5px;">
                <?php
                jimport('joomla.utilities.date');
                    $kunena_db = & JFactory::getDBO();
                    $kunena_db->setQuery ('SELECT `lastvisitDate` FROM #__users WHERE `id` ='.$kunena_my->id);
                    $lastvisitcopy = $kunena_db->loadResult();
                    $lastvisitDate =  new JDate( $lastvisitcopy );
                    if ($lastvisitcopy != '' && $lastvisitcopy != '00-00-0000 00:00:00')
                    {
                        echo '<strong>'. _LAST_VISIT .':</strong> '.$lastvisitDate->toFormat(JText::_('DATE_FORMAT_LC1'))."<br />";
                    }
                ?>
                        </div>
                </div>
                <div style="padding-top:5px;">
                        <input type="submit" name="Submit" class="fb_button" value="<?php echo _PROFILEBOX_LOGOUT; ?>" />
                        <input type="hidden" name="option" value="com_user" />
                        <input type="hidden" name="task" value="logout" />
                        <input type="hidden" name="return" value="<?php echo $return; ?>" />
                </div>
        </div>
        <div>
                <div class="fb_profilebox_link">
                        <?php echo $jr_profilelink; ?>
                </div><br />
                <div class="fb_profilebox_link">
                <a href = "<?php echo $jr_latestpost ; ?>"><?php echo _PROFILEBOX_SHOW_LATEST_POSTS; ?></a>
                </div><br />
                <div class="fb_profilebox_link"><?php echo CKunenaLink::GetSearchLink($fbConfig, 'search', '', 0, 0, _KUNENA_SEARCH_ADVSEARCH);?>
                </div><br />
                                <?php
                    $user_fields = @explode(',', $fbConfig->annmodid);

                    if (in_array($kunena_my->id, $user_fields) || $kunena_my->usertype == 'Administrator' || $kunena_my->usertype == 'Super Administrator') {
                    $is_editor = true;
                    }
                    else {
                    $is_editor = false;
                    }
                    if ($is_editor) {
                ?>
                <div class="fb_profilebox_link">
                        <a href = "<?php echo CKunenaLink::GetAnnouncementURL($fbConfig, 'show');?>"><?php echo _ANN_ANNOUNCEMENTS; ?> </a>
                </div>
                        <?php } ?>
        </div>
                                </td>
            <?php
                        if (JDocumentHTML::countModules('kunena_profilebox'))
                        {
                        ?>
                        <td>
                                <div class = "fb_profilebox_modul">
                                <?php
                                        $document        = &JFactory::getDocument();
                                        $renderer        = $document->loadRenderer('modules');
                                        $options        = array('style' => 'xhtml');
                                        $position        = 'kunena_profilebox';
                                        echo $renderer->render($position, $options, null);
                                ?>
                                </div>
                        </td>
                        <?php
                        }
                        ?>
                </form>
            </tr>
        </tbody>
    </table>
    <?php
}
else
{
    // LOGOUT AREA
    ?>
    <table width = "100%" border = "0" cellspacing = "0" cellpadding = "0"  class = "fb_profilebox">
        <tbody id = "topprofilebox_tbody">
            <tr>
                                <td valign = "top" class = "td-1  fbm fb_profileboxcnt" align="left">
                    <form action="index.php" method="post" name="login">
                                <div class="k_guest">
                        <?php echo _PROFILEBOX_WELCOME; ?>, <b><?php echo _PROFILEBOX_GUEST; ?></b>
                                </div>
                                <div class="input" style="clear:both;padding-top:10px;">
                                <span>
                            <label for="modlgn_username"><?php echo _COM_A_USERNAME; ?></label>
                            <input id="modlgn_username" type="text" name="username" class="inputbox fbs" alt="username" size="18" />
                                </span>
                                <span>
                            <label for="modlgn_passwd"><?php echo _KUNENA_PASS; ?></label>
                            <input id="modlgn_passwd" type="password" name="passwd" class="inputbox fbs" size="18" alt="password" />
                                </span>
                                <span>
                     <input type="submit" name="Submit" class="fb_button" value="<?php echo _PROFILEBOX_LOGIN; ?>" />
                         <input type="hidden" name="option" value="com_user" />
                         <input type="hidden" name="task" value="login" />
                         <input type="hidden" name="return" value="<?php echo $return; ?>" />
                         <?php echo JHTML::_( 'form.token' ); ?>
                                </span>
                                </div>
                                <div class="link_block" style="clear:both;padding-top:10px;">
                                        <span class="fb_profilebox_link">
                                <a href="<?php echo $lostpasslink ?>">
                                <?php echo _PROFILEBOX_FORGOT_PASSWORD; ?></a>
                            </span>
                                        <span class="fb_profilebox_link">
                                 <a href="<?php echo $lostuserlink ?>">
                                 <?php echo _PROFILEBOX_FORGOT_USERNAME; ?></a>
                                        </span>
                                 <?php
                                 $usersConfig = &JComponentHelper::getParams( 'com_users' );
                                 if ($usersConfig->get('allowUserRegistration')) : ?>
                                        <span class="fb_profilebox_link">
                                     <a href="<?php echo $registerlink ?>">
                                         <?php echo _PROFILEBOX_CREATE_ACCOUNT; ?></a>
                                        </span>
                                 <?php endif; ?>
                                        </div>
                                                </form>
                                </td>
                        <?php
                        if (JDocumentHTML::countModules('kunena_profilebox'))
                        {
                        ?>
                        <td>
                                <div class = "fb_profilebox_modul">
                                <?php
                                        $document        = &JFactory::getDocument();
                                        $renderer        = $document->loadRenderer('modules');
                                        $options        = array('style' => 'xhtml');
                                        $position        = 'kunena_profilebox';
                                        echo $renderer->render($position, $options, null);
                                ?>
                                </div>
                        </td>
                        <?php
                        }
                        ?>
            </tr>
        </tbody>
    </table>
<?php
}
?>
